import functionnodes.FunctionNode;
import data.Value;

/**
 * @author loaner
 */
class functionnodes.FunctionNodeCons extends FunctionNode {
	
	function FunctionNodeCons() {
		super();
		funcname = "cons";
//		type = FunctionNode.MACRO;
	}
	
	public function reduceValues( scope:Object, values:Array ) : Value
	{
		//for now let's assume we're getting one Value object whose type is Value.XMLNODE
		var returnXML:XMLNode = values[ 1 ].raw();
		var firstarg:Value = values[ 0 ];
		trace("CONS is starting with firstarg " + firstarg + " and returnXML " + returnXML );
		returnXML = returnXML.cloneNode( true );
		returnXML.insertBefore( firstarg.getXML(), returnXML.firstChild );
		trace("CONS RETURNING " + returnXML );
		var returnval:Value = new Value( Value.XMLNODE, returnXML );
		return returnval;
	}
}